Map Business Online SDK
Application API

Getting Started with Application API

Here are the steps required to start using Map Business Online Application API.

  1. Create a new Window Forms Application in Visual Studio.
  2. Add reference to the MBO.dll assembly. Choose one that corresponds to the .NET framework you use:
    • .NET Framework 3.5: <SDK install folder>\Bin\DotNet35\MBO.dll
    • .NET Framework 4.0+: <SDK install folder>\Bin\DotNet40\MBO.dll

    MBO.dll depends on other assemblies from Bin folder. When you build the project they will be automatically copied to the output folder.

  3. Add <SDK install folder>\Config\MBO.dll.config file to the root of the project. In the file's Properties window set "Copy to Output Directory" to "Copy Always".
    Note that by default MBO.dll searches for MBO.dll.config file in the same folder where the assembly is located. If you want to change that, you would need to specify the path to the config file in Config.Path property.
  4. For C#. Add the following line to the using section. Most of the API types are defined in MBO namespace.
    using MBO;
    For Visual Basic. In the project's Properties window, on References tab find and check MBO namespace in Imported namespaces section.
  5. Add the following member field declaration to the default Form1.
    ''' <summary>
    ''' Application window reference.
    ''' </summary>
    Private _applicationWindow As ApplicationWindow
    /// <summary>
    /// Application window reference.
    /// </summary>
    private ApplicationWindow _applicationWindow;
  6. Add a button to the Form1 and double click on it to generate click event handler.
  7. Add the following code to the click handler:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ' Load Map Business Online application with user account credentials. The method will also load the last-used map.
        _applicationWindow = ApplicationWindow.LoadApplicationWindow(Me, FormWindowState.Maximized, Nothing, Nothing, New Credentials(_email, _password))
    
        ' Finally create a new map. Discard changes made in current map.
        _applicationWindow.Application.NewMap(MapRegion.USA, options:=NewMapOptions.DiscardCurrentMapModifications)
    
        ' Get the map.
        Dim map As IMap = _applicationWindow.Application.Map
    End Sub
    private void button1_Click(object sender, EventArgs e)
    {
        // Load Map Business Online application with user account credentials. The method will also load the last-used map.
        _applicationWindow = ApplicationWindow.LoadApplicationWindow(this, FormWindowState.Maximized, null, null, new Credentials("<Your MBO account e-mail>", "<Your MBO account password>"));
    
        // Finally create a new map. Discard changes made in current map.
        _applicationWindow.Application.NewMap(MapRegion.USA, options: NewMapOptions.DiscardCurrentMapModifications);
    
        // Get the map.
        var map = _applicationWindow.Application.Map;
    }
  8. In the code above replace "<Your MBO account e-mail>" and "<Your MBO account password>" with your real MBO user account credentials.
  9. MBO application window runs in a separate thread thus if you close the main Form1 the MBO window won't be closed automatically. Add the following code that will take care about that.
    Private Delegate Sub CloseApplication()
    
    Private Sub ControlForm_FormClosing(sender As System.Object, e As System.EventArgs) Handles MyBase.FormClosing
        ' If Map Business Online application window was shown and not closed
        If _applicationWindow IsNot Nothing AndAlso Not _applicationWindow.IsDisposed Then
            ' suppress a prompt about not saved current map modifications and close the window.
            _applicationWindow.ShowPromptOnClose = False
            _applicationWindow.Invoke(New CloseApplication(Sub() _applicationWindow.Close()))
        End If
    End Sub
    // Note: below we just added FormClosing event handler in the constructor generated by default.
    public Form1()
    {
        InitializeComponent();
        FormClosing += new FormClosingEventHandler(ControlForm_FormClosing);
    }
    
    private delegate void CloseApplication();
    
    private void ControlForm_FormClosing(object sender, FormClosingEventArgs e)
    {
        // If Map Business Online application window is still open
        if (_applicationWindow != null && !_applicationWindow.IsDisposed)
        {
            // suppress a prompt about not saved current map modifications and close the window.
            _applicationWindow.ShowPromptOnClose = false;
            _applicationWindow.Invoke(new CloseApplication(() => _applicationWindow.Close()));
        }
    }
  10. Finally build and start the application. Click the button you have added to the form. That will load Map Business Online and create new map. While loading the main form will wait and won't respond to mouse events.
  11. That is it. You can use loaded map object to manipulate the map (see IMap interface).
See Also